package com.czy.service.impl;

import com.czy.mapper.OperateLogMapper;
import com.czy.pojo.OperateLog;
import com.czy.pojo.PageResult;
import com.czy.service.OperateLogService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OperateLogServiceImpl implements OperateLogService {

    @Autowired
    private OperateLogMapper operateLogMapper;

    @Override
    public PageResult<OperateLog> page(Integer page, Integer pageSize) {

        //1. 设置分页参数
        PageHelper.startPage(page, pageSize);

        //2.执行SQL语句
        List<OperateLog> operateLogList = operateLogMapper.list();

        //3.解析查询结果，并封装数据
        Page<OperateLog> p = (Page) operateLogList;

        return new PageResult<OperateLog>(p.getTotal(),p.getResult());
    }
}
